//
//  HQExcempleDetailViewController.m
//  MobileiOS
//
//  Created by 郝庆松 on 2018/5/17.
//  Copyright © 2018年 PCITC. All rights reserved.
//

#import "HQExcempleDetailViewController.h"
#import "HQBigImageViewController.h"

@interface HQExcempleDetailViewController ()

@end

@implementation HQExcempleDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"我的案例详情";
    
    [self setViewData];
}

/**
 设置样式图片
 */
-(void)setViewData{
    [_tupian setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.dataInfo[@"case_img"]]] placeholderImage:nil success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull image) {
        _tupian.image = image;
        _imageHegithConstraint.constant = (SCREEN_WIDTH/(image.size.width/ image.size.height));
    } failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) {

    }];
    // 风格
    _fengGe.text = [NSString stringWithFormat:@"%@",self.dataInfo[@"plot_name"]];
    // 客户名称
    [self sourceLabel:_kehunicheng withTitle:@"客户名称: " withData:self.dataInfo[@"case_name"]];
    // 联系方式
    [self sourceLabel:_lianxifangshi withTitle:@"联系方式: " withData:self.dataInfo[@"case_phone"]];
    // 设计理念
    [self sourceLabel:_shejilinian withTitle:@"设计理念: " withData:self.dataInfo[@"designer_content"]];
}

-(void)sourceLabel:(UILabel *)sourceLabel withTitle:(NSString *)title withData:(NSString *)data{
    NSString *data2 = data;
    if(!data2){
        data2 = @"***";
    }
    NSMutableAttributedString *attributeStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%@",title,data2]];
    [attributeStr addAttribute:NSForegroundColorAttributeName value:[self colorHexValue:0x647180] range:NSMakeRange(0,[title length])];
    [attributeStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0,[title length])];
    
//    [attributeStr addAttribute:NSForegroundColorAttributeName value:[self colorHexValue:0x233040] range:NSMakeRange([title length],[data2 length])];
//    [attributeStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange([title length],[data2 length])];
    sourceLabel.attributedText = attributeStr;
}

- (IBAction)lookBigImage:(id)sender {
    HQBigImageViewController *bigImageVc = [[HQBigImageViewController alloc]init];
    bigImageVc.imageURL = self.dataInfo[@"case_img"];
    [self presentViewController:bigImageVc animated:YES completion:nil];
}

@end
